package Five;
import java.util.Scanner;

   
public class Main {
	
	private int balance;
	public synchronized void deposit(int money) {
		this.balance += money;
		notifyAll();
	}
	public synchronized void withdraw(int money) {
		while((this.balance-money)<0){
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		this.balance-=money;
		 if(balance<0) 
		        throw new IllegalStateException(balance+"");				
	}
	
}
